package com.example.date;

import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.junit.jupiter.api.Test;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.LineCaptcha;
import cn.hutool.core.date.DateBetween;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Console;
import cn.hutool.core.util.ReUtil;
import cn.hutool.system.RuntimeInfo;
import cn.hutool.system.SystemUtil;

public class TestDate {

	@Test
	public void test01() {
		String[] a = {"abc","bcd","def"};
		System.out.println(a);
		Console.log(a);
	}
	
	@Test
	public void test02() {
		Console.log("This is Console log for {} .", "test");
		Console.error("this is error console log for {}","hello");
	}
	
	@Test
	public void test03() {
//		String content = "ZZZaaabbbccc中文1234";
//		Pattern pattern = Pattern.compile(regex, Pattern.DOTALL);
//		Matcher matcher = pattern.matcher(content);
//		if(matcher.find()) {
//			String result = matcher.group();
//		}
	}
	
	@Test
	public void test04() {
		String content = "ZZZaaabbbccc中文1234";
		String delFirst = ReUtil.delFirst("(\\w)aa(\\w)", content);
		Console.log(delFirst);
	}
	
	@Test
	public void test05() {
		LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200, 100);
		lineCaptcha.write("d:/line.png");
		Console.log(lineCaptcha.getCode());
		boolean verify = lineCaptcha.verify("12345");
		Console.log(verify);
	}
	
	@Test
	public void test06() {
		Date date = DateUtil.date();
		Console.log(date);
		System.out.println(date);
		DateTime date2 = DateUtil.date(Calendar.getInstance());
		Console.log(date2);
		DateTime date3 = DateUtil.date(System.currentTimeMillis());
		String now = DateUtil.now();
		Console.log(now);
		String today = DateUtil.today();
		Console.log(today);
	}
	private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	@Test
	public void test07() {
		long start = System.currentTimeMillis();
        System.out.println("***获取并入库自有统计结果数据开始：" + sdf.format(new Date())+"***");
        
        //...............do something
        System.out.println();
        Console.log("...............do something..............");
        System.out.println();
        
        long end = System.currentTimeMillis();
        System.out.println("***"+"获取并入库自有统计结果数据结束：" + sdf.format(new Date()) + "；耗时："
                + (end - start) / 1000d + "秒"+"***");
	}
	
	@Test
	public void test08() throws InterruptedException {
//		long start = System.currentTimeMillis();
//        System.out.println("***获取并入库自有统计结果数据开始：" + sdf.format(new Date())+"***");
		Date start = new Date();
        Console.log("***获取并入库自有统计结果数据开始：{} ***", DateUtil.now());
        
        //...............do something
        System.out.println();
        Console.log("...............do something..............");
        Thread.sleep(3000);
        System.out.println();
        
//        long end = System.currentTimeMillis();
//        System.out.println("***"+"获取并入库自有统计结果数据结束：" + sdf.format(new Date()) + "；耗时："
//                + (end - start) / 1000d + "秒"+"***");
        Console.log("***获取并入库自有统计结果数据结束：{}；耗时：{}秒 ***",DateUtil.now(), DateUtil.between(start,new Date() , DateUnit.HOUR));
	}
	
	@Test
	public void test09()  {
		RuntimeInfo runtimeInfo = SystemUtil.getRuntimeInfo();
		long maxMemory = runtimeInfo.getMaxMemory();
		Console.log(maxMemory);
	}
	
	@Test
	public void test10() throws IOException  {
		String path = "config.properties";
		InputStream openStream = this.getClass().getResource(path).openStream();
	}
	
	
	
	
	
	
	
}
